<?php abstract class modAuth implements ifModule {
	public static function Process (array $Args, array $Files) {
		if (Auth::Permission () and isset ($Args ['action'])) switch ($Args ['action']) {
			case 'login':
				if (isset ($Args ['user']) and isset ($Args ['password'])) {
					if (Auth::Check ($Args ['user'], $Args ['password'])) {
						Auth::Login ($Args ['user']);
						XReq::Record ('You have successfully logged in.');
					} else {
						Auth::Logout ();
						XReq::Record ('Access denied.');
					}
				}
			break;
			case 'logout':
				Auth::Logout ();
				XReq::Record ('You have successfully logged out.');
			break;
		}
	}
	public static function Form () { ?>
		<form action="" method="post">
		<?php if ($User = Auth::User ()) { ?>
			hello <?php HTML::E ($User) ?>
			<button type="submit" name="<?php HTML::E (__CLASS__) ?>[action]" value="logout">logout</button>
		<?php } else { ?>
			<label>user: <input type="text" name="<?php HTML::E (__CLASS__) ?>[user]"/></label>
			<label>password: <input type="password" name="<?php HTML::E (__CLASS__) ?>[password]"/></label>
			<button type="submit" name="<?php HTML::E (__CLASS__) ?>[action]" value="login">Login</button>
		<?php } ?>
		</form>
<?php }
} ?>